#!/bin/bash

# Webhook 配置
SECRET="b63929404f905971d61d7"
WEBHOOK_URL="https://www.duzhaosongyue.com"  # 请确认正确的webhook端点

# GitLab Push Event JSON 示例
JSON_BODY='{"ref":"refs/heads/main","repository":{"name":"Brief-pro","git_ssh_url":"git@jihulab.com:duzhaosongyue-springboot/brief-pro.git"}}'

echo "Testing GitLab webhook..."
echo "URL: $WEBHOOK_URL"
echo "Secret: ${SECRET:0:8}..."  # 只显示前8位

# 发送 GitLab webhook 请求（不需要计算签名）
curl -v -X POST \
  -H "Content-Type: application/json" \
  -H "X-Gitlab-Token: $SECRET" \
  -H "X-Gitlab-Event: Push Hook" \
  -H "User-Agent: GitLab/15.0" \
  -d "$JSON_BODY" \
  "$WEBHOOK_URL"

echo -e "\nRequest completed."